<template>
  <div class="table-page-search-wrapper">
    <el-form :model="searchForm" ref="searchForm" label-width="100px" class="demo-ruleForm">
      <el-row :gutter="10">
        <el-col :md="8" :sm="12" :xs="24">
          <el-form-item label="商品名称:">
            <el-input v-model="searchForm.goodsName" placeholder="请输入商品名称" />
          </el-form-item>
        </el-col>
        <el-col :md="8" :sm="12" :xs="24">
          <el-form-item label="商品条码:">
            <el-input v-model="searchForm.barCode" placeholder="请输入条码或后四位" />
          </el-form-item>
        </el-col>
        <el-col :md="8" :sm="12" :xs="24">
          <el-form-item label="商品类目:">
            <el-cascader
              :options="categoryIdList"
              v-model="pid"
              @change="categoryIdChange"
              placeholder="请选择商品类目"
              :props="{ checkStrictly: true }"
              style="width:100%"
            ></el-cascader>
          </el-form-item>
        </el-col>
        <el-col :md="8" :sm="12" :xs="24">
          <el-form-item label="实物库存:">
            <el-input v-model="searchForm.highActualStock" placeholder="最低" style="width:48%" />
            <span>-</span>
            <el-input v-model="searchForm.lowActualStock" placeholder="最高" style="width:48%" />
          </el-form-item>
        </el-col>
        <el-col :md="8" :sm="12" :xs="24">
          <div style="margin-left:30px">
            <el-button type="primary" icon="el-icon-search" @click="searchAction()">查询</el-button>
            <el-button icon="el-icon-refresh" @click="resetSearch()" style="margin-left: 8px;">重置</el-button>
          </div>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import { platformgoodscategorytree } from "@/api/shop/platformProcurementInventory/inventoryList.js";
export default {
  name: "search",
  data() {
    return {
      searchForm: {},
      pid:[],
      categoryIdList: [], //类目
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    searchAction() {
      //执行搜索
      this.$emit("search");
    },
    resetSearch() {
      this.searchForm = {};
      // this.zdsj = []
      this.pid = []
      this.$emit("resetSearch");
    },
    getSearchForm() {
      //获取高级搜索条件
      return {
        ...this.searchForm,
      };
    },
    getList() {
      platformgoodscategorytree({ businessType: "" }).then((val) => {
        //类目
        //商品类目
        let data = val.data.data;
        console.log(data);
        this.categoryIdList = data.map((item) => {
          return {
            value: item.categoryId,
            label: item.categoryName,
            children: item.children.map((items) => {
              return {
                value: items.categoryId,
                label: items.categoryName,
              };
            }),
          };
        });
      });
    },
    categoryIdChange(e) {
      if (e.length > 1) {
        this.searchForm.categoryId = e[1];
      } else {
        this.searchForm.categoryId = e[0];
      }
    },
  },
};
</script>


<style lang="less">
</style>>
